package demo.controller;

import demo.dao.*;
import demo.logger.LoggerHelper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;
import java.io.*;
import demo.service.*;

import com.mysql.fabric.xmlrpc.base.Member;

public class Iyoga
{
	public static void console()
	{
		Scanner sc = new Scanner(System.in);// 定义输入流
		ServiceMember member = new ServiceMember();
		ServiceCard card = new ServiceCard();
		while (true)
		{
			System.out.print(">iyoga ");
			String inParam = sc.next();
			if (inParam.equals("exit"))
			{
				System.out.println("程序运行结束");
				LoggerHelper.info("Iyoga.console", "程序运行结束");
				break;
			} else if (inParam.equals("add-member"))
			{
				String name = sc.next();
				String address = sc.next();
				String job = sc.next();
				member.addMember(name, address, job);
			} else if (inParam.equals("add-card"))
			{
				String name = sc.next();
				String type = sc.next();
				int count = 100;
				if (type.equals("次卡"))
				{
					count = Integer.parseInt(sc.next());
				} else if (!type.equals("年卡"))
				{
					System.out.println("请输入正确的卡的类型!");
					LoggerHelper.debug("Iyoga.addCard", "输入了错误的卡类型");
				}
				card.addCard(name, type, count);
			} else
			{
				System.out.println(inParam + " 不是一个有效的指令");
				LoggerHelper.debug("Iyoga.console", "输入了错误的指令");
			}
		}
	}

	public static void main(String[] args) throws Exception
	{
		console();
	}
}
